import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/wrapper/normal_form_wrapper.dart';
import 'package:flutter/material.dart';

class PayslipsItem extends StatelessWidget {
  final String name;
  final String timeRange;
  final String status;
  final String currency;
  final double amount;
  final String errorMessage;

  const PayslipsItem(
      {Key key,
      this.name,
      this.errorMessage,
      this.timeRange,
      this.status,
      this.currency,
      this.amount})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return NormalFormWrapper(
      leftPadding: getDp(32),
      rightPadding: getDp(32),
      topPadding: getDp(24),
      bottomPadding: getDp(23),
      hasBottomBorder: true,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              SizedBox(
                width: getDp(200),
                child: Text(
                  name,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(18),
                    fontWeight: FontWeight.w700,
                    height: 14 / 18,
                  ),
                ),
              ),
              SizedBox(
                height: getDp(8),
              ),
              Text(
                timeRange,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(14),
                  fontWeight: FontWeight.w400,
                  height: 14 / 14,
                ),
              ),
            ],
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              if (status == 'open')
                RedTagWidget(
                  content: 'Unpaid',
                ),
              if (status == 'closed')
                GreenTagWidget(
                  content: 'Paid',
                ),
              if (status == 'double_submission')
                RedTagWidget(
                  content: 'Error',
                ),
              SizedBox(
                height: getDp(6),
              ),
              if (errorMessage == null)
                Text(
                  '$currency ${CashUtils.formatCashAmount(amount)}',
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 14 / 16,
                  ),
                )
              else
                Text(
                  errorMessage,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(12),
                    fontWeight: FontWeight.w400,
                    height: 14 / 12,
                  ),
                )
            ],
          ),
        ],
      ),
    );
  }
}
